package com.zch.starter.metrics.prometheus.springboot.starter.utils;

import io.micrometer.core.instrument.Tag;
import org.apache.commons.collections.MapUtils;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

public class TagsUtils {

    public static  List<Tag> getTags(Map<String, String> tagMap) {
        if (MapUtils.isEmpty(tagMap)) {
            tagMap = new ConcurrentHashMap<>();
        }
        return tagMap.entrySet().stream().map(entry -> Tag.of(entry.getKey(), entry.getValue()))
                .collect(Collectors.toList());
    }
}
